<template>
   <view class="container">
     <view class="userInfo" @click="routeTo('/pages/my/myinfo')">
       <view class="avatar">
         <image :src="userInfo.avatar?userInfo.avatar:'../../static/images/noavatar.png'" mode="scaleToFill" />
       </view>
       <view class="" style="flex: 1">
         <view class="nickname">{{userInfo.name}}</view>
         <view>性别: {{userInfo.gender}}</view>
         <view>{{userInfo.yardName}}{{userInfo.orgName}}</view>
       </view>
       <van-icon name="arrow" />
     </view>
     <view class="card">
       <view class="card_title">
         <view class="card_r">调动记录</view>
         <van-icon name="arrow" />
       </view>
       <view class="card_content">
          <view class="card_list" v-for="(item,index) in cardList" :key="index">
              <view>{{item.time }}</view>
              <view>{{ item.palce }}</view>
          </view> 
       </view>
     </view>
     <view class="card">
       <view class="card_title">
         <view class="card_r">晋升记录</view>
         <van-icon name="arrow" />
       </view>
       <view class="card_content">
          <view class="card_list" v-for="(item,index) in cardList" :key="index">
              <view>{{item.time }}</view>
              <view>{{ item.palce }}</view>
          </view> 
       </view>
     </view>
     <view class="card">
       <view class="card_title">
         <view class="card_r">奖惩记录</view>
         <van-icon name="arrow" />
       </view>
       <view class="card_content">
          <view class="card_list" v-for="(item,index) in cardList" :key="index">
              <view>{{item.time }}</view>
              <view>{{ item.palce }}</view>
          </view> 
       </view>
     </view>
     <view style="margin-top:50rpx">
		<van-button type="default"  class="w-full" @click="quit">退出登录</van-button> 
	 </view>
     <view style="height: 100rpx;"></view>
   </view>
 </template>
 <script setup>
  import {menuTreeSelectorApi,getLoginUserApi} from '@/api'
  import { onLoad,onShow } from '@dcloudio/uni-app';
  const userInfo=ref({})
  const cardList=ref([
    {time:'2012-12月————2023-12月',palce:'检察院'},
    {time:'2012-12月————2023-12月',palce:'检察院'}
  ])
 onShow(async()=>{
  const res = await getLoginUserApi();
  userInfo.value =res.data 
 })
  const routeTo=(url)=>{
    uni.navigateTo({
     url:url
    })
  }
  const quit = () => {
  	uni.showModal({
  		title: "提示",
  		content: "确定退出吗？",
  		success: function (res) {
  			if (res.confirm) {
  				cache.clear();
  				uni.reLaunch({
  					url: "/pages/login/index",
  				});
  			} else if (res.cancel) {
  			}
  		},
  	});
  };
 </script>
 <style lang="scss" scoped>
 .container {
   padding: 20rpx 30rpx;
   font-size: 28rpx;
 }
 .card {
   padding: 30rpx;
   background: #fff;
   margin-top: 30rpx;
   border-radius: 20rpx;
   .card_title{
     display: flex;
     padding-bottom: 20rpx;
     font-weight: 600;
     border-bottom: 1px solid #e1e1e1;
     .card_r{
       flex:1;
     }
   }
   .card_list{
     padding-top: 20rpx;
     font-size: 26rpx;
     color: #666;
     display: flex;
     justify-content: space-between;
   }
 }
 .userInfo {
   display: flex;
   background: #fff;
   border-radius: 20rpx;
   font-size: 26rpx;
   color: #666;
   padding: 40rpx 30rpx;
   align-items: center;
   .nickname {
     font-size: 32rpx;
     font-weight: 600;
     color: #333;
     margin-bottom: 20rpx;
   }
   .avatar {
     width: 100rpx;
     height: 100rpx;
     display: block;
     margin-right: 30rpx;
     image {
       width: 100rpx;
       height: 100rpx;
       display: block;
       border: 20rpx;
     }
   }
 }
 </style>
 